package model;


/**
 * Represent different value that can be passed to a solver/preprocessor as parameter value.
 * 
 * @author GRONOWSKI Stephane svan001@aol.com
 * 
 *         igsat 2010
 * 
 */
public enum ParameterValue {
	NOT_USED ("", "not used"), TRUE ("true", "true"), FALSE ("false", "false"), RANDOM ("rnd", "rnd");

	private String	val;
	private String	xmlValue;

	/**
	 * Return the string value of the parameter := toString.
	 * 
	 * @return the string value of the parameter := toString
	 */
	public String getVal() {
		return val;
	}

	private ParameterValue(String val, String xmlValue) {
		this.val = val;
		this.xmlValue = xmlValue;
	}

	/**
	 * Return the xmlValue, value that is supposed to written in the xml exportation.
	 * 
	 * @return the xmlValue
	 */
	public String getXmlValue() {
		return xmlValue;
	}

	/**
	 * Return the {@link ParameterValue} associate to a value find in a XML exportation.
	 * 
	 * @param value
	 *            xml value
	 * @return the associate {@link ParameterValue}
	 */
	public static ParameterValue getValueFromXML(String value) {
		for (ParameterValue val : values())
			if (val.getXmlValue().equals(value))
				return val;
		return null;
	}
}
